package com.xizi.leetcode周赛;

public class _5768找到需要补充粉笔的学生编号 {

    public int chalkReplacer(int[] chalk, int k) {
        long sum = 0;
        for (int i = 0; i < chalk.length; i++) {
            sum += chalk[i];
        }
        k %= sum;
        for (int i = 0; i < chalk.length; i++) {
            if (chalk[i] > k) {
                return i;
            } else {
                k -= chalk[i];
            }
        }
        return 0;
    }
}
